package com.example.date;

import java.time.Duration;
import java.time.LocalDateTime;

/**
 * @author hej
 * @date 2022/10/25 11:30
 */
public class DateDelay {
    //计算时间差
    public static void main(String[] args) {
        LocalDateTime start = LocalDateTime.of(2022, 5, 9, 1, 1);
        LocalDateTime end = LocalDateTime.of(2022, 5, 8, 1, 1);
        System.out.println("相差的天数: " + Duration.between(start, end).toDays() + "天");
        System.out.println("相差的小时数: " + Duration.between(start, end).toHours() + "小时");
        System.out.println("相差的分钟数: " + Duration.between(start, end).toMinutes() + "分钟");
        System.out.println("相差的毫秒数: " + Math.abs(Duration.between(start, end).toMillis()) + "毫秒");
    }
}
